<!doctype html>
<?php
    /*
     * setcookie() must appear before the html tag
     * syntax: setcookie(name, value, expire, path, domain);
     */
    setcookie("user" , "honey" , time()+3600);
    /*
     * session_start() must appear before the html tag
     */
    session_start();
?>
<html>
    <head>
        <title>Cookies</title>
    </head>
    <body>
        <?php
            /*
             * Verify if the cookie has been set
             */
            if(isset($_COOKIE["user"]))
            {
                echo "Welcome, " . $_COOKIE["user"] . ".<br/>";
            }
            else
            {
                echo "Welcome, guest.<br/>";
            }
           /*
            * To delete a cookie, set the time in the past
            * setcookie("user" , "" , time()-3600);
            */ 
            
            /*
             * Verify if the "views" variable has already been set
             * If it has, then increment it
             * Else, create it
             */
            if(isset($_SESSION["views"]))
            {
                $_SESSION["views"]+=1;
            }
            else
            {
                $_SESSION["views"]=1;
            }
            echo "You have visited this page " . $_SESSION["views"] . " times.";
           /*
            * To delete a session, use 
            * unset($_SESSION['views']) for a specific variable or
            * session_destroy();
            */ 
        ?>
    </body>
</html>